package factory.simple;

import factory.entity.*;
import factory.method.*;

public class SimpleFactory {
    public static NewsDao createNewsDao(String type) throws Exception {
        NewsDao newsDao=null;
        NewsFactory factory=null;
        if(type.equals("+")){
            factory=new AddNewsDaoFactory();
            newsDao=factory.createNewsDao();
        }
        else if(type.equals("-")){
            factory=new SubtraNewsDaoFactory();
            newsDao=factory.createNewsDao();
        }
        else if(type.equals("*")){
            factory=new MultiNewsDaoFactory();
            newsDao=factory.createNewsDao();
        }
        else if(type.equals("/")){
            factory=new DivisionNewsDaoFactory();
            newsDao=factory.createNewsDao();
        }
        else if(type.equals("%")){
            factory=new PressNewsDaoFactory();
            newsDao=factory.createNewsDao();
        }
        else {
            throw new RuntimeException("所需要的运算没有");
        }
        return newsDao;
    }
}
